package com.gdcvi.scan;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * ScoreBoard:得分板
 */
public class ScoreBoard{
    private Player winner;
    private Player loser;
    private String dateTime;
    private String msg;
    private Hand hand;
    private static ScoreBoard  instance = new ScoreBoard();
    public ScoreBoard() {
    }

    public static ScoreBoard getInstance(){
        return  instance;
    }

    public void setDateTime(String dateTime) {
        this.dateTime = dateTime;
    }

    public Hand getHand() {
        return hand;
    }

    public void setHand(Hand hand) {
        this.hand = hand;
    }

    public static void setInstance(ScoreBoard instance) {
        ScoreBoard.instance = instance;
    }

    public Player getWinner() {
        return winner;
    }

    public void setWinner(Player winner) {
        this.winner = winner;
    }

    public Player getLoser() {
        return loser;
    }

    public void setLoser(Player loser) {
        this.loser = loser;
    }

    public String getDateTime() {
        return dateTime;
    }

    public void setDateTime(Date dateTime) {
        this.dateTime = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss").format(dateTime);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "得分板{" +
                "winner=" + winner +
                ", loser=" + loser +
                ", dateTime=" + dateTime +
                ", msg='" + msg + '\'' +
                '}';
    }

   /* public void 打印(ScoreBoard scoreBoard) {
        ObjectOutputStream out = null;
        try {

            File file = new File("D:\\JAVA idea\\得分板.txt");
            if (file.exists()) {
                file.createNewFile();
            }
            out = new ObjectOutputStream(new FileOutputStream(file, true));
            out.writeObject(scoreBoard);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.flush();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
*/

}
